<?php
/**
 * Created by PhpStorm.
 * User: w-pc
 * Date: 2017/03/04
 * Time: 22:32
 */
namespace Admin\Controller;
use Think\Controller;
class UserController extends CommonController {
    public function index(){

        $flag = request('post','int','flag',0);
        if($flag==1){
            $header_photo = upload_file($_FILES['header_photo']);
//            echo $header_photo;
//            exit();
            if($header_photo!='') $index_arr['header_photo'] = $header_photo;
            $about_photo = upload_file($_FILES['about_photo']);
            if($about_photo!='') $index_arr['about_photo'] = $about_photo;
            $index_arr['header_text'] = request('post','str','header_text','');
            $index_arr['about_text'] = request('post','str','about_text','');
            $index_arr['footer_function'] = request('post','str','footer_function','');
            $index_arr['footer_home'] = request('post','str','footer_home','');
            $index_arr['footer_text'] = request('post','str','footer_text','');
            D('Index')->add_Info($index_arr);
        }
        $index_arr = D('Index')->get_Info();
        $this->assign('index',$index_arr);
        $this->display();
    }
    public function ajax(){
        $upfile = $_FILES['upfile'];
//        echo json_encode(array('file_infor'=>'上传失败'));
        D('Index')->add_Info(array('header_photo'=>$upfile['name']));
    }

}